﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 9/9/2009
 * Time: 1:38 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Buaya.Model;

namespace Buaya.Gui
{
	/// <summary>
	/// Description of TimesheetEmployeeForm.
	/// </summary>
	public partial class TimesheetEmployeeForm : BaseForm
	{
		public TimesheetEmployeeForm() : this(new Timesheet())
		{
			
		}
		
		public TimesheetEmployeeForm(Timesheet t)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Util.SwfUtility.SetupComboBox(comboBoxEmployee, SessionFacade.FindAllEmployees(), "Id", "Name");
			Model = t;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			Timesheet t = Model as Timesheet;
			t.Employee = (comboBoxEmployee.DataSource as IList<Employee>)[comboBoxEmployee.SelectedIndex];
			t.Date = dateTimePickerDate.Value;
			t.In = checkBoxInOut.Checked;
			DialogResult = DialogResult.OK;
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
